<template>
	<div class="page-index">
		<div class="hd">
			<view class="" style="display: flex;justify-content: space-between;align-items: center;width: 100%;">
				<div class="info">
					<div class="info-hd">付款给</div>
					<div class="info-bd">乌兰察布市集宁区妇幼保健计划生育服务中心</div>
				</div>
				<div class="info-icon" style="margin-left: 10rpx;">
					<img class="info-icon-img" src="/static/yb/info-icon.png" alt="">
				</div>
			</view>
			<div class="bg"></div>
		</div>
		<div class="bd">
			<div class="box">
				<div class="box-hd">
					<div class="box-hd-label">费用总额</div>
					<div class="box-hd-value">{{data.zfy}}元</div>
				</div>
				<div class="box-bd">
					<div class="box-item">
						<div class="box-bd-label">医保基金支付</div>
						<div class="box-bd-value">{{data.ybje}}元</div>
					</div>
					<div class="box-item">
						<div class="box-bd-label">个人帐户支付</div>
						<div class="box-bd-value">{{data.grje}}元</div>
					</div>
					<div class="box-item">
						<div class="box-bd-label">其他抵扣金额</div>
						<div class="box-bd-value">0元</div>
					</div>
				</div>
				<div class="box-ft">
					<div class="box-ft-label">现金支付</div>
					<div class="box-ft-value">{{data.zfje}}元</div>
				</div>
			</div>
			<div class="bd-append">
				<i class="bd-append-icon"><img class="info-icon-img" src="/static/yb/medical-logo.png" alt=""></i>
				<div class="bd-append-text">医保移动支付</div>
			</div>
		</div>
		<div class="ft">
			<div class="pay">
				<div class="pay-label">您还需支付：</div>
				<div class="pay-value">¥{{data.zfje}}</div>
			</div>
			<div class="btn" @click="YBPay">去支付</div>
		</div>

	</div>
</template>

<script>
	export default {
		name: 'PageIndex',
		data() {
			return {
				OrderNo: '',
				data: '',
				ybpayurl:'',
				payAuthNo:'',
				uldLatlnt:'',
				Returnurl:'http://jnwechat.xztongyong.cn/h5/#/pages/register/Scheduling/record/record'
			}
		},
		onLoad: function(option) {
			// OrderNo    payAuthNo   uldLatlnt/
			let item=JSON.parse(option.obj)
			this.OrderNo=item.OrderNo
			this.payAuthNo=item.payAuthNo
			this.uldLatlnt=item.uldLatlnt
			this.YBJSXX()
		},
		methods: {
			YBPay(){
				
				if(this.ybpayurl==''){
					this.$request("HisRegist", "YBPay", {
						OrderNo: this.OrderNo,
						PayAuthNo:this.payAuthNo,
						UldLatlnt:this.uldLatlnt,
						Returnurl:this.Returnurl
					}).then(res => {
						console.log("获取医保支付订单信息", res)
						if (res.code == 1) {
							// RegisterId:'',
							// payurl:''
							window.location.href= res.data.payurl
						} else {
							uni.hideLoading();
							uni.showToast({
								title: res.msg,
								icon: 'none',
								duration: 2000
							});
						}
					})
				}else{
					uni.showToast({
						title: '未获得ybpayurl',
						icon: 'none',
						duration: 2000
					});
				}
			},
			YBJSXX() {
				this.$request("HisRegist", "YBJSXX", {
					OrderNo: this.OrderNo
				}).then(res => {
					console.log("获取医保支付订单信息", res)
					if (res.code == 1) {
						this.data = res.data
						this.ybpayurl=res.data.ybpayurl
					} else {
						uni.hideLoading();
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						});
					}
				})
			},
		}
	}
</script>

<style scoped>
	@import './index.css';
	@import './actionsheet.css';
</style>